#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define ERROR -999

typedef int ElementType;
struct SNode
{
    ElementType Data;
    struct SNode* Next;
};
typedef struct SNode* PtrToSNode;
typedef PtrToSNode Stack;

Stack MakeEmpty()
{
    Stack S = (Stack) malloc(sizeof(struct SNode));
    S->Next = NULL;
    return S;
}

bool IsEmpty(Stack S)
{
    return S->Next == NULL;
}

bool Push(Stack S, ElementType X)
{
    PtrToSNode TmpCell = (PtrToSNode) malloc(sizeof(struct SNode));
    TmpCell->Data = X;
    TmpCell->Next = S->Next;
    S->Next = TmpCell;
    return true;
}

ElementType Pop(Stack S)
{
    if (IsEmpty(S)) {
        printf("堆栈空\n");
        return ERROR;
    }
    PtrToSNode FirstCell = S->Next;
    ElementType result = FirstCell->Data;
    S->Next = FirstCell->Next;
    free(FirstCell);
    return result;
}